<?php
/**
 * Created by PhpStorm.
 * User: WangXiaoHong
 * Date: 15-9-28
 * Time: 下午2:19
 */
include "/var/www/html/new/d/module/phpqrcode/phpqrcode.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>二维码在线生成工具</title>
    <link rel="stylesheet" href="images/base.css">
    <link rel="stylesheet" href="images/QRcode.css"></head>
<body>
<div class="container">
    <div class="clearfix mb20">
        <h1 class="fl">二维码在线生成工具</h1>

    </div>

    <div class="QRcode clearfix">

        <div class="QRcode-editor fl pr">
            <ul class="QRcode-class clearfix">
                <li class="active" name="text">输入内容</li>

            </ul>
            <div class="QRcode-classContent">
                <div class="urlORText">
                    <p class="explain">网址/文本生成二维码</p>
                    <p class="pr">

                    <form id="iform" name="iform" method="post" action=""><textarea name="content" id="content"><?php echo $_POST['content']; ?></textarea>
                    </p>
                    <div class="none" id="bookmarkShell">

                        </p>
                    </div>
                </div>

            </div>
            <div class="quick"><input name="go" type="submit" id="go" onclick="" value="输入内容后，点击这里就可以生成QR" />
                <input name="done" type="hidden" value="done" />

                </form></div>

        </div>
        <div class="QRcode-show fr">
            <p class="tc"></p>
            <div class="pr zoom">
                <p class="tc" id="QRcode-showBox">
                    <?php
                    if ($_POST['done']){
                        if($_POST['content']){
                            $c = $_POST['content'];

                            $len = strlen($c);
                            if ($len <= 360){
                                $file = fopen("t.txt","r+");
                                flock($file,LOCK_EX);
                                if($file) {
                                    $get_file = fgetss($file);
                                    $t = $get_file+1;
                                    $file2 = fopen("t.txt","w+");
                                    fwrite($file2,$t);
                                }
                                flock($file,LOCK_UN);
                                fclose($file);
                                fclose($file2);

                                QRcode::png($c, 'png/'.$t.'.png');
                                $sc = urlencode($c);
                                echo '<img src="png/'.$t.'.png" /><br />'.$c;
                            }
                            else {
                                echo '亲！信息量过大。';
                            }
                        }
                        else {
                            echo '亲！你没有输入内容。';
                        }
                    }
                    else {
                        echo '二维码将会出现在这里。';
                    }
                    ?>
                </p>

            </div>
        </div>
    </div>

    <div id="footer" class="tc mt20">
        <a href="http://www.shenyisyn.org">回到程序员在囧途网站首页</a>>>
    </div>
</div>
</body></html>